
from selenium.webdriver.support.select import Select


class Base():
    def __init__(self, driver):
        self.driver = driver

    #打开网站，窗口最大化
    def open(self, url):
        self.driver.get(url)
        self.driver.maximize_window()

    #元素定位
    def find_element(self, locator):
        return self.driver.find_element(*locator)

    #输入
    def input(self, locator, text):
        self.driver.find_element(*locator).send_keys(text)

    #点击
    def click(self, locator):
        self.driver.find_element(*locator).click()

    #进内帧
    def into_frame(self,frame_name):
        self.driver.switch_to.frame(frame_name)

    #出内帧
    def out_frame(self):
        self.driver.switch_to.default_content()

    #下拉框选择
    def select_by_text(self, locator, text):
        Select(self.find_element(*locator)).select_by_visible_text(text)

